package creational.builder.simple;


public class Bike {

    private String frame;
    private String seat;

    // 全参构造(构造器内属性赋值成员变量)
    public Bike(Builder builder) {
        frame = builder.frame;
        seat =builder.seat;
    }



    // 内部构造器
    public static final class Builder{
        private String frame;
        private String seat;

        public Builder() {
        }

        // 成员方法 传参赋值成员变量 返回Builder(方便链式变成)
        public Builder frame(String var) {
            frame = var;
            return this;
        }

        // 成员方法 传参赋值成员变量 返回Builder(方便链式变成)
        public Builder seat(String var) {
            seat = var;
            return this;
        }

        // builder方法 调用类的构造方法 传入构造器
        public Bike builder(){
            return new Bike(this);
        }
    }

    @Override
    public String toString() {
        return "Bike{" +
                "frame='" + frame + '\'' +
                ", seat='" + seat + '\'' +
                '}';
    }
}
